#include "Precomp.h"
#include "AnimationProfile.h"

AnimationProfile::AnimationProfile(int w, int h,
		int xoffset, int yoffset, int numFrameInRow,
		int xGap, int yGap, int numFrame)
{
	sf::Rect<int> frameRect(xoffset,yoffset,xoffset+w,yoffset+h);//the first frame rect
	int frameInRow=0;
	int row=0;
	for(int i=0;i<numFrame;++i)//generating the frameRects
	{
		frames.push_back(frameRect);
		++frameInRow;
		if(frameInRow=numFrameInRow)//we have come to the last frame in the row
		{
			frameInRow=0;//go the the first frame of the next row
			++row;
			frameRect.Top=yoffset+row*(h+yGap);
			frameRect.Bottom=frameRect.Top+h;
		}
		frameRect.Left=xoffset+frameInRow*(w+xGap);
		frameRect.Right=frameRect.Left+w;		
	}
}

const sf::Rect<int>& AnimationProfile::getFrame(int index) const
{
	return frames[index];
}

unsigned int AnimationProfile::getFrameCount() const
{
	return frames.size();
}

AnimationProfile::~AnimationProfile()
{
}
